package com.zline.foodraise.http;

import android.content.Context;

import com.zline.foodraise.R;
import com.zline.foodraise.util.TUtil;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

/**
 * Created by heshantao on 15/7/20.
 * 处理http 返回异常结果
 */
@EBean
public class HttpErro {
    @RootContext
    Context cxt;

    //普通错误
    public void showCommonErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 301:
                TUtil.showShort(cxt, R.string.null_paramers);
                break;
            case 302:
                TUtil.showShort(cxt, R.string.invaild_token);
                break;
            case 303:
                TUtil.showShort(cxt, R.string.verify_paramers_failed);
                break;
            case 304:
                TUtil.showShort(cxt, R.string.decode_failed);
                break;
            case 305:
                TUtil.showShort(cxt, R.string.encrypt_failed);
                break;
            case 306:
                TUtil.showShort(cxt, R.string.paramers_wrong);
                break;
            case 307:
                TUtil.showShort(cxt, R.string.no_such_method);
                break;
            case 500:
                TUtil.showShort(cxt, R.string.service_exception);
                break;
            default:
                break;
        }
    }

    //登录相关错误
    public void showLoginErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 1001:
                TUtil.showShort(cxt, R.string.user_not_exit_wrong_pwd);
                break;
            case 1002:
                TUtil.showShort(cxt, R.string.illegal_phoneNumber);
                break;
            case 1003:
                TUtil.showShort(cxt, R.string.send_auth_code_faile);
                break;
            case 1004:
                TUtil.showShort(cxt, R.string.verify_auth_code_faile);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }
    }


    //关注相关错误
    public void showAttentionErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 1101:
                TUtil.showShort(cxt, R.string.can_not_attention_yourself);
                break;
            case 1102:
                TUtil.showShort(cxt, R.string.can_not_attention_again);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }
    }


    //用户相关错误
    public void showUserErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 1201:
                TUtil.showShort(cxt, R.string.user_exit);
                break;
            case 1202:
                TUtil.showShort(cxt, R.string.nick_name_used);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }
    }


    public void showCommentErroResult(int resultCode){
        String erro = null;
        switch (resultCode) {
            case 1301:
                TUtil.showShort(cxt, R.string.not_apply_yourself);
                break;
            case 1302:
                TUtil.showShort(cxt, R.string.not_comment_twice);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }

    }


    //动态相关错误
    public void showDynamicErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 1601:
                TUtil.showShort(cxt, R.string.con_not_support_again);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }
    }


    //项目相关错误
    public void showProjectErroResult(int resultCode) {
        String erro = null;
        switch (resultCode) {
            case 1601:
                TUtil.showShort(cxt, R.string.con_not_support_again);
                break;
            case 1602:
                TUtil.showShort(cxt, R.string.not_apply_project);
                break;
            default:
                showCommonErroResult(resultCode);
                break;
        }
    }

}
